var AjaxUrls = {
	list : "",
	save : "",
};
(function(){
	function getList(){
		getList.status.loading();
		$.ajax({
			url : AjaxUrls.list,
			type : "GET",
			dataType : "JSON",
			success : function(res){
				if(res && res.code && res.list){
					if(!G.isEmpty(res.list)){
						getList.status.success();
						buildList(res.list)
					}else{
						getList.status.empty();
					}
				}else{
					getList.status.bus();
				}
			},
			error : function(xhr,text){
				if(text == "timeout"){
					getList.status.error("timeout");
				}else{
					getList.status.error("bus");
				}
			}
		})
	}
	getList.status = {
		loading : function(){ //loading
			var loading = '<li class="loading" style="text-align:center; line-height:1; height:400px;"><p style="color:#aeaeae; font-size:12px; padding-top:150px;">加截数据...</p><img src="../images/cart/loading_1.gif" alt="" /></li>';
			$("#mainCart").html(loading);
			$("#botSumary").hide();
		},
		empty : function(){ //空数据
			var html = '<li style="height:400px; line-height:400px; text-align:center; color:#b4b4b4;" class="removeToEmpty">没有商品，去<a style="margin:0 3px; font-weight:bold; color:#3375b8" href="#">首页</a>逛逛</li>';
			$("#mainCart").html(html);
			$("#botSumary").hide();
		},
		success : function(){ //成功请求
			$("#botSumary").show();
		},
		error : function(type){
			//type : timeout //超时
			//type : server  //服务器端出错
			//type : bus     //业务逻辑出错
			var timeout = '<li style="height:400px; line-height:400px; text-align:center; color:#b4b4b4;" class="removeToEmpty">请求超时，请稍后刷新重试</li>';
			var server = '<li style="height:400px; line-height:400px; text-align:center; color:#b4b4b4;" class="removeToEmpty">服务器出错 / 帐号登录过期，请重新登录</li>';
			var bus = '<li style="height:400px; line-height:400px; text-align:center; color:#b4b4b4;" class="removeToEmpty">请求出错，请稍后刷新重试</li>';
			if(type == "timeout"){
				$("#mainCart").html(timeout);
			}else if(type == "server"){
				$("#mainCart").html(server);
			}else if(type == "bus"){
				$("#mainCart").html(bus);
			}
			$("#botSumary").hide();
		}
	};
	function buildList(datas){
		var html = "";
		var isSelected = "false";
		var cls = "";
		var readOnly = "";
		for(var i in datas){
			var data = datas[i];
			var type = data["type"];
			var lid = i;
			var landtit = data["title"];
			var subs = data["subs"];
			var isSelected = data.isSelected == 1 ? "checked='checked'" : "";
			var readOnly = data.isSelected == 1 ? "" : "readOnly='true'";
			var cls = data.isSelected == 1 ? "" : "unselect";
			
			
		}
		$("#mainCart").html(html);
		countTotal();
	}




 



$(function(){
	getList();
	UI.init();
})


})();